<?php
namespace Systemht\Controller;
use Think\Controller;
class MsgController extends IndexController{
	public function index(){
		$model = M('Msg');
		$count = $model->count();
		$Page       = new \Think\Page($count,C('PAGE_NUM'));
		$show       = $Page->Homeshow();
		$Page->lastSuffix = false;
		$this->assign('show',$show);
		//分页查询数据
		$data = $model->order('ctime DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('data',$data);
		$this->display();
	}
	//查看
	public function info(){
		$id = I('get.id');
		$data = M('Msg')->where(array('id'=>$id))->find();
		$this->assign('data',$data);
		$this->display();
	}
	public function del(){
		$id = I('post.id');
		$result = M('Msg')->where(array('id'=>$id))->delete();
		if($result){
			$this->ajaxReturn(array('status'=>"OK",'msg'=>'删除成功'));
		}
		else{
			$this->ajaxReturn(array('status'=>"NO",'msg'=>'删除失败'));
		}
	}
	//批量删除
	public function alldel(){
		$id = I('post.id');
		$result = M('Msg')->where(array('id'=>array('in',implode(',',$id))))->delete();
		if($result){
			$this->ajaxReturn(array('status'=>"OK",'msg'=>'删除成功'));
		}
		else{
			$this->ajaxReturn(array('status'=>"NO",'msg'=>'删除失败'));
		}
	}
}